import request from '@/utils/request';

// 查询代码模型详细
export function queryById(id) {
  return request({
    url: '/lcdp/codeModel/queryById/' + id,
    method: 'get',
  });
}

// 分页查询代码模型列表
export function pageList(query) {
  return request({
    url: '/lcdp/codeModel/pageList',
    method: 'get',
    params: query,
  });
}

// 查询已发布的代码模型列表
export function queryRelease(params) {
  return request({
    url: '/lcdp/codeModel/queryRelease',
    method: 'get',
    params,
  });
}

// 查询逻辑删除的代码模型列表
export function queryRecycle(params) {
  return request({
    url: '/lcdp/codeModel/queryRecycle',
    method: 'get',
    params,
  });
}

// 新增代码模型
export function insert(data) {
  return request({
    url: '/lcdp/codeModel/insert',
    method: 'post',
    data: data,
  });
}

// 修改代码模型
export function updateById(data) {
  return request({
    url: '/lcdp/codeModel/updateById',
    method: 'put',
    data: data,
  });
}

// 根据id批量审核
export function auditByIds(ids) {
  return request({
    url: '/lcdp/codeModel/auditByIds/' + ids,
    method: 'put',
  });
}

// 根据id批量反审核
export function unauditByIds(ids) {
  return request({
    url: '/lcdp/codeModel/unauditByIds/' + ids,
    method: 'put',
  });
}
// 导出当前查询列表
export function exports(params) {
  return request({
    url: '/lcdp/codeModel/export',
    method: 'post',
    params,
  });
}

// 删除代码模型
export function deleteByIds(ids) {
  return request({
    url: '/lcdp/codeModel/deleteByIds/' + ids,
    method: 'delete',
  });
}

// 根据id批量还原删除的代码模型
export function recoverByIds(ids) {
  return request({
    url: '/lcdp/codeModel/recoverByIds/' + ids,
    method: 'put',
  });
}
// 根据id批量逻辑删除数据模型
export function removeByIds(ids) {
  return request({
    url: '/lcdp/codeModel/removeByIds/' + ids,
    method: 'delete',
  });
}

// 查询db数据库列表
export function tableList(query) {
  return request({
    url: '/lcdp/codeModel/tableList',
    method: 'get',
    params: query,
  });
}

// 导入表
export function importTable(data) {
  return request({
    url: '/lcdp/codeModel/importTable',
    method: 'post',
    params: data,
  });
}

// 预览生成代码
export function previewTable(tableId) {
  return request({
    url: '/lcdp/codeModel/preview/' + tableId,
    method: 'get',
  });
}

// 生成代码（自定义路径）
export function genCode(tableName) {
  return request({
    url: '/lcdp/codeModel/generate/' + tableName,
    method: 'get',
  });
}

// 同步数据库
export function synchDb(tableName) {
  return request({
    url: '/lcdp/codeModel/synchModelFromTable/' + tableName,
    method: 'get',
  });
}
